Skip to content

test: add package-level Vitest examples for web-cluster and shared packages#1826

Open
JYZ-LESLIE wants to merge 2 commits into
CapSoftware:mainfrom
JYZ-LESLIE:codex/algora-54-testing-bootstrap
Open

test: add package-level Vitest examples for web-cluster and shared packages#1826
JYZ-LESLIE wants to merge 2 commits into
CapSoftware:mainfrom
JYZ-LESLIE:codex/algora-54-testing-bootstrap

Conversation

@JYZ-LESLIE
Copy link
Copy Markdown

@JYZ-LESLIE JYZ-LESLIE commented May 16, 2026

/claim #54

This PR adds a focused, non-overlapping testing bootstrap slice for issue #54 in additional app/package workspaces beyond the current desktop/utils scope.

What's included

  • add test scripts (pnpm exec vitest run) to:
    • apps/web-cluster
    • packages/web-api-contract
    • packages/web-domain
    • packages/sdk-recorder
  • add one example test per workspace:
    • apps/web-cluster/src/cluster/container-metadata.test.ts
    • packages/web-api-contract/src/desktop.test.ts
    • packages/web-domain/src/utils.test.ts
    • packages/sdk-recorder/src/core/mime-types.test.ts

Validation

  • pnpm --filter=@cap/web-cluster test
  • pnpm --filter=@cap/web-api-contract test
  • pnpm --filter=@cap/web-domain test
  • pnpm --filter=@cap/sdk-recorder test

All four pass locally.

Notes

  • Kept this PR intentionally scoped and mergeable; no lockfile churn and no unrelated dependency updates.
  • The sdk-recorder example explicitly checks preferred codec priority order to provide a stronger baseline pattern for future tests.

AI-assisted with Codex; diff reviewed before submission.

Greptile Summary

This PR bootstraps Vitest test coverage in four previously-untested workspaces (apps/web-cluster, packages/sdk-recorder, packages/web-api-contract, packages/web-domain) by adding a test script and one representative test file per package.

  • All four test files are logically sound: assertions match the source schemas and Effect service implementations, mock cleanup is handled correctly via afterEach, and the codec-priority test accurately reflects the PREFERRED_MIME_TYPES iteration order.
  • All four package.json files add the test script but omit vitest from devDependencies, so pnpm exec vitest run will fail on a clean install or in CI where vitest is not hoisted from another workspace. No vitest.config.ts is provided for any of the new packages, diverging from the pattern established by every other workspace that already has tests.

Confidence Score: 3/5

The test logic is correct, but the missing vitest dependency will cause all four new test scripts to fail in CI or on a fresh clone.

The individual test files are well-written and faithfully cover their respective modules, but every package.json in the PR omits vitest from devDependencies. Running pnpm exec vitest run in an isolated package context resolves the binary from that package's own node_modules/.bin — and since vitest is never declared there, the command silently relies on hoisting from another workspace package. This is fragile enough to break turbo run test or any filtered run on a clean CI environment.

All four package.json files need vitest added to devDependencies before the test scripts are reliable.

Important Files Changed

Filename Overview
apps/web-cluster/package.json Adds test script but omits vitest from devDependencies, making the script unreliable outside of environments where vitest is hoisted from another workspace
packages/sdk-recorder/package.json Adds test script without adding vitest to devDependencies; same fragile-hoisting issue as web-cluster
packages/web-api-contract/package.json Adds a scripts block with test but no devDependencies block — vitest is entirely undeclared
packages/web-domain/package.json Adds test script without adding vitest to devDependencies; same fragile-hoisting issue as the other three packages
apps/web-cluster/src/cluster/container-metadata.test.ts Tests ContainerMetadata.Default for both the env-absent fallback to 0.0.0.0 and the ECS metadata fetch path; cleanup via afterEach is correct
packages/sdk-recorder/src/core/mime-types.test.ts Verifies codec priority ordering and the empty-string fallback; mock and assertion counts are accurate against the source
packages/web-api-contract/src/desktop.test.ts Covers hex-color validation and the discriminated-union upload variant's min(1) guard; assertions are correct against the zod schemas
packages/web-domain/src/utils.test.ts Tests the optional Effect Schema helper for Some, None (from null), and absent-key (undefined) cases; all three assertions match the schema's decoding contract
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/web-cluster/package.json:8
**`vitest` missing from devDependencies**

`pnpm exec vitest run` resolves the binary from the local `node_modules/.bin`. Since `vitest` is not declared as a `devDependency` here (or in any of the other three affected packages), the command will fail on a clean install or in CI. It likely passes locally only because vitest is hoisted from another workspace package (e.g. `apps/web`), which is an implicit, unreliable dependency. The same gap affects `packages/sdk-recorder`, `packages/web-api-contract`, and `packages/web-domain`.

### Issue 2 of 2
apps/web-cluster/package.json:8
**No `vitest.config` file for the new test suites**

None of the four new workspaces ship a `vitest.config.ts`, while every existing workspace that has a `test` script (`apps/desktop`, `apps/discord-bot`, `apps/web`) provides one. Without a config, Vitest uses default settings — no TypeScript path-alias resolution, no custom environment, and no `globals` injection. Adding at least a minimal config file per package aligns with the project's existing pattern.

Reviews (1): Last reviewed commit: "test: add package-level vitest examples ..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

@superagent-security superagent-security Bot added contributor:verified Contributor passed trust analysis. pr:verified PR passed security analysis. labels May 16, 2026
@JYZ-LESLIE
Copy link
Copy Markdown
Author

Validation follow-up: all newly added package/app tests pass locally.\n\n- pnpm --filter=@cap/web-cluster test\n- pnpm --filter=@cap/web-api-contract test\n- pnpm --filter=@cap/web-domain test\n- pnpm --filter=@cap/sdk-recorder test\n\nCurrent failing status appears to be the external Vercel authorization gate (team-side authorize-to-deploy), same pattern as other recent PRs.

"build": "pnpm run --filter @cap/web-cluster^... build",
"build:docker": "cd ../.. && docker build -f apps/web-cluster/Dockerfile -t ghcr.io/brendonovich/cap-web-cluster:latest ."
"build:docker": "cd ../.. && docker build -f apps/web-cluster/Dockerfile -t ghcr.io/brendonovich/cap-web-cluster:latest .",
"test": "pnpm exec vitest run"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 vitest missing from devDependencies

pnpm exec vitest run resolves the binary from the local node_modules/.bin. Since vitest is not declared as a devDependency here (or in any of the other three affected packages), the command will fail on a clean install or in CI. It likely passes locally only because vitest is hoisted from another workspace package (e.g. apps/web), which is an implicit, unreliable dependency. The same gap affects packages/sdk-recorder, packages/web-api-contract, and packages/web-domain.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web-cluster/package.json
Line: 8

Comment:
**`vitest` missing from devDependencies**

`pnpm exec vitest run` resolves the binary from the local `node_modules/.bin`. Since `vitest` is not declared as a `devDependency` here (or in any of the other three affected packages), the command will fail on a clean install or in CI. It likely passes locally only because vitest is hoisted from another workspace package (e.g. `apps/web`), which is an implicit, unreliable dependency. The same gap affects `packages/sdk-recorder`, `packages/web-api-contract`, and `packages/web-domain`.

How can I resolve this? If you propose a fix, please make it concise.

"build": "pnpm run --filter @cap/web-cluster^... build",
"build:docker": "cd ../.. && docker build -f apps/web-cluster/Dockerfile -t ghcr.io/brendonovich/cap-web-cluster:latest ."
"build:docker": "cd ../.. && docker build -f apps/web-cluster/Dockerfile -t ghcr.io/brendonovich/cap-web-cluster:latest .",
"test": "pnpm exec vitest run"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No vitest.config file for the new test suites

None of the four new workspaces ship a vitest.config.ts, while every existing workspace that has a test script (apps/desktop, apps/discord-bot, apps/web) provides one. Without a config, Vitest uses default settings — no TypeScript path-alias resolution, no custom environment, and no globals injection. Adding at least a minimal config file per package aligns with the project's existing pattern.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web-cluster/package.json
Line: 8

Comment:
**No `vitest.config` file for the new test suites**

None of the four new workspaces ship a `vitest.config.ts`, while every existing workspace that has a `test` script (`apps/desktop`, `apps/discord-bot`, `apps/web`) provides one. Without a config, Vitest uses default settings — no TypeScript path-alias resolution, no custom environment, and no `globals` injection. Adding at least a minimal config file per package aligns with the project's existing pattern.

How can I resolve this? If you propose a fix, please make it concise.

@JYZ-LESLIE
Copy link
Copy Markdown
Author

/claim #54

@superagent-security superagent-security Bot removed the pr:verified PR passed security analysis. label May 16, 2026
@JYZ-LESLIE
Copy link
Copy Markdown
Author

Addressed the two Greptile findings in commit 4786679:\n\n- Added explicit vitest devDependency to all four affected workspaces (no more hoisted implicit binary dependency).\n- Added minimal vitest.config.ts files for each new test-enabled workspace to align with repo testing patterns.\n- Updated lockfile accordingly.\n\nValidation re-run locally:\n- pnpm --filter=@cap/web-cluster test\n- pnpm --filter=@cap/web-api-contract test\n- pnpm --filter=@cap/web-domain test\n- pnpm --filter=@cap/sdk-recorder test\n\nAll four pass.

@JYZ-LESLIE JYZ-LESLIE force-pushed the codex/algora-54-testing-bootstrap branch from 4786679 to bb3fbf6 Compare May 16, 2026 16:29
@JYZ-LESLIE
Copy link
Copy Markdown
Author

Rebased onto latest main and resolved the lockfile conflict that made this PR DIRTY.

Current head: bb3fbf6

Re-validated after rebase:

  • pnpm --filter=@cap/web-cluster test
  • pnpm --filter=@cap/web-api-contract test
  • pnpm --filter=@cap/web-domain test
  • pnpm --filter=@cap/sdk-recorder test

All pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Bounty claim contributor:verified Contributor passed trust analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant